#include "GravityRigidBodySimulation.h"

namespace coolpool
{

	GravityRigidBodySimulation::GravityRigidBodySimulation(const std::vector<Entity *> & entities, int num_workers, const math_tools::Vector3D & gravity) :
		RigidBodySimulation(entities, num_workers)
	{
		gravity_ = gravity;
	}

	GravityRigidBodySimulation::~GravityRigidBodySimulation()
	{

	}

	void GravityRigidBodySimulation::beforeNextStep()
	{
		DynamicEntitiesPointers * dynamics = getEntitiesContainer()->getDynamicEntities();
		for (unsigned i = 0; i < dynamics->size(); ++i)
		{
			static_cast<RigidBody *>((*dynamics)[i])->addForce(gravity_);
		}
	}
}
